<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>promise的介绍</title>
</head>
<body>
    
</body>
<script>
    let api = new Promise((resolve,reject)=>{
        setTimeout(()=>{
            if(false){ 
                resolve('ok11') 
            }else{
                reject('error') 
            }
        },2000)
    })

    api.then((res)=>{
        console.log(res);
        console.log('promise 请求成功');
    })
    .catch((err)=>{
        console.log(err);
        console.log('promise 请求失败');
    })
</script>
</html>